package org.nepu.scr.indexrate.converter.drillingrate.emergencycapability;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.emergencycapability.Preparedness;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class PreparednessConverter implements AttributeConverter<Preparedness, String> {
    @Override
    public String convertToDatabaseColumn(Preparedness preparedness) {
        return JSONUtil.toJsonStr(preparedness);
    }

    @Override
    public Preparedness convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, Preparedness.class);
    }
}
